import { BrowserWindow, app } from 'electron'

export default function (ipcMain: Electron.IpcMain, mainWindow: BrowserWindow) {
  ipcMain.on('maximize', () => {
    if (mainWindow.isMaximized()) {
      mainWindow.restore()
    } else {
      mainWindow.maximize()
    }
  })

  ipcMain.on('minimize', () => {
    mainWindow.minimize()
  })

  ipcMain.on('fullScreen', () => {
    if (mainWindow.isFullScreen()) {
      mainWindow.setFullScreen(false)
    } else {
      mainWindow.setFullScreen(true)
    }
  })

  ipcMain.on('close', () => {
    mainWindow.close()
  })

  ipcMain.handle('get-versions', () => {
    return {
      node: process.versions.node,
      chrome: process.versions.chrome,
      electron: process.versions.electron,
      appVersion: app.getVersion()
    }
  })
}
